﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using HtmlAgilityPack;

namespace pachong
{
    class Program
    {
        static void Main(string[] args)
        {
            string url ="";

            HtmlWeb web = new HtmlWeb();

            Random random = new Random();

            List<string> txtContent = new List<string>();

            for (int i = 464341; i < 464391; i++)
            {
                url = $"https://m.75zwxs.com/879688/{i}.html";

                Console.WriteLine(url);

                int t = random.Next(1000, 3050);

                Console.WriteLine(t.ToString());

                Thread.Sleep(t);

                var htmlDoc = web.Load(url);

                var htmlBody = htmlDoc.DocumentNode.SelectNodes("//p");
                
                Console.WriteLine(htmlBody);

                foreach (HtmlNode item in htmlBody)
                {
                    Console.WriteLine(item.InnerText.ToString());

                    txtContent.Add(item.InnerText.ToString());

                }

                string filePath = @"D:\file.txt";

                File.WriteAllLines(filePath, txtContent);

            
            }

            Console.ReadKey();

        }
    }
}
